package com.uouie.common.service;


import com.uouie.common.MqttConnect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

/**
 * @author coder
 * @date 2023-11-09
 * @desc:
 */
@Service
public class MqttPublishImpl implements IMqttPublish {

    @Autowired
    @Lazy
    MqttConnect mqttConnect;

    @Override
    public void send(String topic, String msg) {
        mqttConnect.publish(mqttConnect.getQos(), false, topic, msg);
    }
    
    @Override
    public boolean send(Integer qos, Boolean retained, String topic, String msg) {
        return mqttConnect.publish(qos, retained, topic, msg);
    }

    @Override
    public boolean send(String version, String event, String mac, String msg) {
        return mqttConnect.publish(mqttConnect.getQos(), false, mqttConnect.getPubTopic() + '.' + version + '.' + event + '.' + mac, msg);
    }


}